package com.heima.media.controller;


import com.heima.common.dto.ResponseResult;
import com.heima.media.dto.ChannelDto;
import com.heima.media.entity.WmChannel;
import com.heima.media.service.IWmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {

    @Autowired
    private IWmChannelService wmChannelService;

    //根据名称模糊查询分页列表
    @PostMapping("/list")
    public ResponseResult findList(@RequestBody ChannelDto dto) {
        return wmChannelService.findList(dto);
    }

    //保存频道
    @PostMapping
    public ResponseResult saveWmChannel(@RequestBody WmChannel wmChannel) {
        return wmChannelService.saveWmChannel(wmChannel);
    }

    //查询全部频道
    @GetMapping("/channels")
    public ResponseResult channels() {
        List<WmChannel> list = wmChannelService.list();
        return ResponseResult.okResult(list);
    }
}